﻿using Glue;
using Xunit;

namespace GlueTests.AutoRelaterTests
{
    public class When_automatically_relating_fields
    {
        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public class DomainPerson { public int Id { get; set; } }
        public class GuiPerson { public int Id; }

        public When_automatically_relating_fields()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
        }

        [Fact]
        public void Should_be_default_not_autorelate()
        {
            mapping.AutoRelateEqualNames();
            Assert.Equal(0, mapping.Relations.Count);
        }

        [Fact]
        public void Should_autorelate_if_specified()
        {
            mapping.AutoRelateEqualNames(false, true);
            Assert.Equal(1,mapping.Relations.Count);
            Assert.Equal(RelationDirection.TwoWays,mapping.Relations.Get(x=>x.Id,y=>y.Id).Direction);
        }
    }
}
